@include('backstage/public/_header')
    <style>
        .add_tab td span #thume {
            line-height: 100px;
            color: #d94040;
            font-size: 14px;
            text-align: center;
        }
    </style>
    <div class="result_wrap">
        <div class="result_title">
            <div class="mark">
                <p>帶<i class="require">*</i>為必填項</p>
            </div>
        </div>
        <form id="form_data">
            {{csrf_field()}}
            <input type="hidden" name="id" value="{{ $art_cate->id }}" />
            <table class="add_tab">
                <tbody>
                    <tr>
                        <th width="120"><i class="require">*</i>選擇父級分類：</th>
                        <td>
                            <select name="pid" id="pid">
                                <option value="0">頂級分類</option>
                                @foreach ($cate as $v)
                                    <option value="{{$v->id}}" @if($art_cate->pid==$v->id) selected="selected" @endif>{{$v->type_name}}</option>
                                @endforeach
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <th><i class="require">*</i>分類名稱：</th>
                        <td>
                            <input type="text" class="lg" name="type_name" id="type_name" value="{{ $art_cate->type_name }}">
                            <p>分類名稱可以寫30個字</p>
                        </td>
                    </tr>
                    <tr>
                        <th><i class="require">*</i>分類唯壹標識：</th>
                        <td>
                            <input type="text" name="type_nid" onkeyup="value=value.replace(/[^\w{1,}\-\w{1,}|\w{1,}]/g,'')" value="{{ $art_cate->type_nid }}">
                            <span><i class="fa fa-exclamation-circle yellow"></i>推薦使用英文字符</span>
                        </td>
                    </tr>
                    <tr>
                        <th>分類屬性：</th>
                        <td>
                            <label for=""><input type="radio" value="0" name="type_set" @if($art_cate->type_set==0) checked="checked" @endif>單頁</label>
                            <label for=""><input type="radio" value="1" name="type_set" @if($art_cate->type_set==1) checked="checked" @endif>列表頁</label>
                            <label for=""><input type="radio" value="2" name="type_set" @if($art_cate->type_set==2) checked="checked" @endif>跳轉</label>
                        </td>
                    </tr>
                    <tr>
                        <th>跳轉地址：</th>
                        <td>
                            <input type="text" name="type_url" value="{{ $art_cate->type_url }}">
                            <span><i class="fa fa-exclamation-circle yellow"></i>僅在分類屬性為跳轉時有效</span>
                        </td>
                    </tr>
                    <tr>
                        <th>是否在新窗口打開：</th>
                        <td>
                            <label for=""><input type="radio" value="1" name="is_blank" @if($art_cate->is_blank==1) checked="checked" @endif>是</label>
                            <label for=""><input type="radio" value="0" name="is_blank" @if($art_cate->is_blank==0) checked="checked" @endif>否</label>
                        </td>
                    </tr>
                    <tr>
                        <th>排序：</th>
                        <td>
                            <input type="text" onkeyup="value=value.replace(/[^\d{1,}\-\d{1,}|\d{1,}]/g,'')" name="sort_order" maxlength="3" id="sort_order" value="{{ $art_cate->sort_order }}">
                            <p>只能是數字</p>
                        </td>
                    </tr>
                    <tr>
                        <th>是否隱藏：</th>
                        <td>
                            <label for=""><input type="radio" value="1" name="is_hidden" @if($art_cate->is_hidden==1) checked="checked" @endif>是</label>
                            <label for=""><input type="radio" value="0" name="is_hidden" @if($art_cate->is_hidden==0) checked="checked" @endif>否</label>
                        </td>
                    </tr>
                </tbody>
            </table>
            <div class="btn_group">
                <input type="button" value="提交" id="btnSub" onclick="onSubmit();">
                <input type="button" class="back" onclick="history.go(-1)" value="返回">
            </div>
        </form>
        <div class="tips">
            <h3>修改文章分類說明</h3>
            <p>1、帶<i class="require">*</i>為必填項，不允許為空</p>
            <p>2、頂級分類無父分類</p>
            <p>3、分類唯壹標誌為分類鏈接的網址標識，排序：數字越大越靠前</p>
            <p>4、點擊提交 -&gt; 修改分類，返回-&gt; 回到文章分類</p>
        </div>
    </div>
    <script type="text/javascript">
        var vfTime = 2;
        var timer=null;
        function setTime(){
            vfTime --;
            if(vfTime<=0){
                vfTime = 0;
                clearInterval(timer);
            }
        }
        function onSubmit(){
            var pid = $("#pid").val();
            var type_name = $("#type_name").val();
            var type_nid = $("#type_nid").val();
            if (vfTime!=0 && timer!=null){
                layer.msg('操作過於頻繁', {icon: 7,anim: 6});
                // setTimeout(function(){$("#chiContent").focus();}, 1500);
                return false;
            }
            if (pid==''){
                layer.msg('請選擇文章分類', {icon: 5,anim: 6});
                // setTimeout(function(){$("#chiContent").focus();}, 1500);
                return false;
            }
            if (type_name=='') {
                layer.msg('分類名稱不能為空', {icon: 5,anim: 6});
                setTimeout(function(){$("#type_name").focus();},0);
                return false;
            }
            if (type_nid=='') {
                layer.msg('分類唯壹標識不能為空', {icon: 5,anim: 6});
                setTimeout(function(){$("#type_nid").focus();},0);
                return false;
            }
            var form = new FormData(document.getElementById("form_data"));
//             var req = new XMLHttpRequest();
//             req.open("post", "${pageContext.request.contextPath}/public/testupload", false);
//             req.send(form);
            $.ajax({
                url:"{{$doedit}}",
                type:"post",
                data:form,
                processData:false,
                contentType:false,
                dataType : "json",
                success:function(data){
                    if(data.status==1){
                        layer.msg(data.message, {icon: 6});
                        setTimeout(function(){
                            window.location.href=data.jumpUrl;
                        },2000);
                    }else if(data.status==-1){
                        layer.alert(data.message, {icon: 2,anim:6});
                    }else{
                        layer.msg(data.message, {icon: 5});
                    }
                    
                    clearInterval(timer);
                    timer = setInterval(setTime, 1000, "1");
                    
                },
                error:function(e){
                    layer.msg(e, {icon: 5,anim: 6});
                    clearInterval(timer);
                    timer = setInterval(setTime, 1000, "1");
                }
            });
        }
    </script>
@include('backstage/public/_footer')